package ua.com.globallogic.training.generics;

import java.util.LinkedList;
import java.util.List;

public class Collections {

   public static <T extends Fruit, U extends T> void copyAll(List<U> in, List<T> out) {
       for (U element : in) {
           out.add(element);
       }
   }

    public static <U extends Fruit> void printCollection(List<U> collection) {
        for (U element : collection) {
            System.out.println(element.getName());
        }
    }

    public static <T extends Comparable<T>> List<T> copyAllElementsBiggerThan(T elementToCompare, List<T> inputCollection) {
        List<T> result = new LinkedList<T>();
        for (T element : inputCollection) {
            if (element.compareTo(elementToCompare) > 0) {
                result.add(element);
            }
        }
        //How do we handle the case when no elements have been added to result? Return null?
        return result;
    }
}

